package com.gtw;

import com.gtw.iterator.Aggregate;
import com.gtw.iterator.ConcreteAggregate;

import java.util.Iterator;

public class Client {

    public static void main(String[] args){
        //声明一个容器
        Aggregate aggregate = new ConcreteAggregate();
        aggregate.add("aaa");
        aggregate.add(123);
        aggregate.add(123.45);
        //遍历容器中元素
        Iterator iterator = aggregate.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
